<?php
include 'checkLogin.php';
@$name = $_REQUEST['name'];
@$phone = $_REQUEST['phone'];

include 'db/li.php';

@$branch_names = dbSelectAll('select name from branch');
foreach ($branch_names as $branch_name){
	if($branch_name['name'] == $name){
		$mes = "已有此部门";
		include 'addBranch.php';
		die;
	}
}
@$flog = dbInsert('insert into branch(name,phone) values(:name,:phone)',array('name'=>$name,'phone'=>$phone));
if(!$flog){
	$mes = "添加部门失败";
	include 'addBranch.php';
	die;
}
header('Refresh:0;url=branchList.php');